local joy__longyin = fk.CreateSkill {

  name = "joy__longyin",

  tags = {  },

}



joy__longyin:addEffect(fk.CardUsing, {
  name = "joy__longyin",
  anim_type = "support",
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(joy__longyin.name) and target.phase == Player.Play and data.card.trueName == "slash" and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local cards = player.room:askForDiscard(player, 1, 1, true, joy__longyin.name, true, ".", "#joy__longyin-invoke::"..target.id, true)
    if #cards > 0 then
      event:setCostData(self, cards)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:throwCard(event:getCostData(self), joy__longyin.name, player, player)
    if not data.extraUse then
      data.extraUse = true
      target:addCardUseHistory(data.card.trueName, -1)
    end
    if data.card.color == Card.Red and not player.dead then
      player:drawCards(1, joy__longyin.name)
    end
    if data.card.suit == Fk:getCardById(event:getCostData(self)[1]).suit and player:usedSkillTimes("joy__jiezhong", Player.HistoryGame) > 0 then
      player:setSkillUseHistory("joy__jiezhong", 0, Player.HistoryGame)
    end
  end,
})

return joy__longyin